package com.example.exam9;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class exam9 extends AppCompatActivity {
    TextView tvWelcome;
    Button btnSetting;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_exam9);
        tvWelcome = findViewById(R.id.tv_welcome);
        btnSetting = findViewById(R.id.btn_setting);
        btnSetting.setOnClickListener(v -> {
            Intent intent = new Intent(this, editActivity.class);
            startActivityForResult(intent, 1);
        });
    }

    @Override
    protected void onStart() {
        super.onStart();
        tvWelcome.setText(getString(R.string.welcome, " "));
    }

    @Override
    protected void onResume() {
        super.onResume();
        String username = getSharedPreferences("data", MODE_PRIVATE)
                .getString("username", " ");
        tvWelcome.setText(getString(R.string.welcome, username));
    }
}